package leetcode1

func twoSum(nums []int, target int) []int {
	dataMap := map[int]int{}
	var res []int
	for i, num := range nums {
		if k, ok := dataMap[target-num]; ok {
			res = append(res, k, i)
			break
		}
		dataMap[num] = i
	}
	return res
}
